package com.pro.controller;

import com.pro.pojo.JsUserOrder;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserReturnUnsubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * ClassName:JsUserReturnUnsubController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2021/11/25 下午 2:03
 * @Author: WYH
 */
@Controller
@RequestMapping("/unsub")
public class JsUserReturnUnsubController {

    @Autowired
    private JsUserReturnUnsubService jsUserReturnUnsubService;

    @RequestMapping("/getAllReGoo")
    @ResponseBody
    public JsonData getAllReGoo(String orderPaymentChannel, String orderSource) {
        orderPaymentChannel = orderPaymentChannel  != null  ? "%"+orderPaymentChannel+"%":"%%";
        orderSource = orderSource = orderSource != null ? "%"+orderSource+"%":"%%";
        List<JsUserOrder> allCourse = jsUserReturnUnsubService.getAllReGoo(orderPaymentChannel, orderSource);
        int count = jsUserReturnUnsubService.count(orderPaymentChannel, orderSource);
        return allCourse != null ? JsonData.buildSuccess(allCourse,count):JsonData.buildError("服务端错误");
    }


    @RequestMapping("/delReGoo")
    @ResponseBody
    public JsonData delReGoo(Integer orderId) {
        Boolean aBoolean = jsUserReturnUnsubService.delReGoo(orderId);
        return aBoolean!= false ? JsonData.buildSuccess(aBoolean):JsonData.buildError("服务端错误");
    }
}
